<template>
	<view class="login">
		<view class="title">
			<view class="login_text active">
				登录
				<text class="active"></text>
			</view>
			<navigator url="/pages/register/index">
				<view class="register_text ">
					注册
				</view>
			</navigator>

		</view>
		<view class="login_box">
			<view class="username">
				<text>用户名/手机号</text>
				<input type="text" placeholder="请输入用户名/手机号" v-model="username" />
			</view>
			<view class="password">
				<text>密码</text>
				<input type="password" placeholder="请输入登录密码" v-model="password_login" />
			</view>
			<view class="btn" @click="isLogin()">
				登录
			</view>
			<!-- <view class="tips">
				<text>登录遇到问题</text>
				<navigator url="" class="forget">
					忘记密码?
				</navigator>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		Login
	} from '../../api/api.js'
	export default {
		data() {
			return {
				username: '',
				password_login: ''
			}
		},
		onLoad() {},
		methods: {
			isLogin() {
				Login({
					username: this.username,
					password_login: this.password_login
				}).then(res => {
					if(res.status == 1){
						uni.setStorageSync('token',res.token)
						uni.switchTab({
							url:'/pages/user/index'
						})
					}else{
						uni.showToast({
							title:res.message,
							icon:'none'
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.login {
		padding-top: 20px;
		font-size: 16px;
		height: calc(100vh - 64px);
		background: #1d3f2b;

		.title {
			display: flex;
			justify-content: space-around;
			align-items: center;
			color: #fff;
			width: 50%;
			margin: 0 auto;

			view {
				display: flex;
				flex-direction: column;
				align-items: center;
			}

			text {
				display: block;
				width: 30px;
				height: 3px;
				background: #fff;
				margin-top: 3px;
			}
		}

		.active {
			font-size: 24px;
		}

		.login_box {
			background: #fff;
			width: 80%;
			padding: 5%;
			padding-top: 10%;
			border-radius: 8px;
			margin: 20px auto;

			text {
				margin: 10px 0;
				display: block;
				font-weight: bold;
				font-size: 14px;
			}

			input {
				border: 1px solid #377751;
				outline: 0;
				border-radius: 5px;
				height: 40px;
				padding-left: 15px;
				margin-top: 10px;
			}
		}

		.tips {
			display: flex;
			justify-content: space-between;
			font-size: 14px;
			align-items: center;

			text {
				font-weight: normal;
				color: #777;
			}

			.forget {
				color: $uni-text-color;
			}
		}


	}
</style>
